/*
 * johnson
 *
 */

package com.lxd.pattern.factory.trainning.simple;

import com.lxd.pattern.factory.trainning.Apple;
import com.lxd.pattern.factory.trainning.Huawei;
import com.lxd.pattern.factory.trainning.Phone;
import com.lxd.pattern.factory.trainning.Xiaomi;

public class SimpleFactory {
    // 增加新的产品导致代码修改，不符合开闭原则
    public Phone getPhone(String type){
        if ("小米".equals(type)) {
            return new Xiaomi();
        } else if ("苹果".equals(type)) {
            return new Apple();
        } else if ("华为".equals(type)){ // 增加新手机
            return new Huawei();
        }else {
            System.out.println("unknow phone type:" + type);
            return null;
        }
    }
}
